package com.wkbb.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author luowenyan
 * @version V1.0
 * @className VerifyUtil
 * @description
 * @date 2019/7/26 19:32
 */
public class VerifyUtil {

    private static final String MOBILE_REGEX = "^1[3456789]\\d{9}$";

    private static final String CHAR_REGEX="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]";

    private static final String ZH_CHAR_REGEX="[\\u4e00-\\u9fa5]";

    /**
     * 验证手机号码
     * @param mobile
     * @return
     */
    public static boolean isMobileNum(String mobile) {
        Pattern pattern = Pattern.compile(MOBILE_REGEX);
        Matcher mat = pattern.matcher(mobile);
        return mat.find();
    }

    /**
     * 校验字符串中是否存在特殊字符
     * @param str
     * @return
     */
    public static boolean checkCharacters(String str){
        Pattern pattern = Pattern.compile(CHAR_REGEX);
        Matcher mat = pattern.matcher(str);
        return mat.find();
    }

    /**
     * 校验字符串中是否存在中文
     * @param str
     * @return
     */
    public static boolean checkZhCharacters(String str){
        Pattern pattern = Pattern.compile(ZH_CHAR_REGEX);
        Matcher mat = pattern.matcher(str);
        return mat.find();
    }

    public static void main(String[] args) {
        //System.out.println(checkCharacters("罗@艳"));
        //^[\u4e00-\u9fa5]{0,}$
        System.out.println(checkZhCharacters("2342349罗94234"));

    }
}
